<template>
  <div class="login">
    <!-- 导航栏 -->
    <van-nav-bar
      class="app-nav-bar"
      title="标题"
      left-arrow
      @click-left="onClickLeft"
    >
      <template #left>
        <van-icon name="cross"/>
      </template>
    </van-nav-bar>
    <!-- /导航栏 -->
    <!-- 登录表单 -->
    <van-form>
      <van-cell-group>
        <van-field
          type="digit"
          clearable
          required
          v-model="user.phone"
          icon-prefix="icon"
          left-icon="shouji"
          placeholder="请输入手机号"
          :rules="[{ required: true }, { pattern, message: '请输入正确的手机号' }]"
        />
        <van-field
          type="digit"
          clearable
          required
          v-model="user.code"
          icon-prefix="icon"
          left-icon="yanzhengma"
          placeholder="请输入验证码"
          :rules="[{ required: true }]"
        >
          <template #button>
            <van-button size="mini" type="primary" class="send-btn" round>发送验证码</van-button>
          </template>
        </van-field>
      </van-cell-group>
      <div class="login-btn">
        <van-button block type="info" @click="onLogin">提交</van-button>
      </div>
    </van-form>
    <!-- /登录表单 -->
  </div>
</template>

<script>
export default {
  name: 'LoginIndex',
  components: {},
  props: {},
  data () {
    return {
      user: {
        phone: '',
        code: ''
      },
      // 正则验证手机号
      pattern: /^[1][3,4,5,7,8][0-9]{9}$/
    }
  },
  computed: {},
  watch: {},
  created () {},
  mounted () {},
  methods: {
    onClickLeft () {
      this.$router.back()
    },
    onLogin () {
      console.log('111')
    }
  }
}
</script>

<style scoped lang="less">
  .login-btn {
    margin: 26px 16px;
    .van-button {
      height: 44px;
      background-color: #6db4fb;
      border-radius: 5px;
      border-color: #6db4fb;
      .van-button__text {
        font-size: 15px;
      }
    }
  }
  .send-btn {
    background-color: #ededed;
    color: #666;
    font-size: 11px;
    border-color: #ededed;
    padding: 4px 10px;
  }
</style>
